import { request } from '@/utils/axios/axios'
import type { CategoryVo } from '@/api/category/type'

// url
enum API {
  CATEGORY = 'category',
}
// 查询全部分类，以树形结构返回
export const queryAllCategories = (): Promise<CategoryVo[]> => {
  return request.get<null, CategoryVo[]>(API.CATEGORY)
}
// 添加品牌
export const addCategory = (data: CategoryVo): Promise<string> => {
  return request.post<CategoryVo, string>(API.CATEGORY, data)
}
// 更新分类
export const updateCategory = (data: CategoryVo): Promise<string> => {
  return request.put(API.CATEGORY, data)
}
// 删除分类
export const deleteCategories = (categoryIds: number[]): Promise<string> => {
  return request.delete<CategoryVo, string>(API.CATEGORY, { data: categoryIds })
}
